package com.zwy.springinner.controller;

import com.zwy.springinner.event.PayEvent;
import com.zwy.springinner.event.RefoundEvent;
import lombok.extern.java.Log;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

@RestController
@Log
public class IndexController {

    @Resource
    private ApplicationContext applicationContext;

    @GetMapping("/pay")
    public void index() {
        applicationContext.publishEvent(PayEvent.builder().message("HelloWorld").build());
        log.info("消息发送结束");
    }

    @GetMapping("/refound")
    public void refound() {
        applicationContext.publishEvent(new RefoundEvent("not null message"));
        log.info("退款消息发送结束");
    }
}
